home *** CD-ROM | disk | FTP | other *** search
- /*
- * tclTest.c --
- *
- * Test driver for TCL.
- *
- * Copyright 1987-1991 Regents of the University of California
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appears in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /user6/ouster/tcl/tclTest/RCS/tclTest.c,v 1.19 91/11/17 14:07:21 ouster Exp $ SPRITE (Berkeley)";
- #endif
-
- #include <resources.h>
- #include <events.h>
- #include <files.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <errno.h>
- #include <string.h>
- #include <stdarg.h>
- #include "tcl.h"
- #include "tclExtend.h"
-
- char dumpFile[100];
- int quitFlag = 0;
-
- char *initCmd =
- "if [file exists [info library]:init.tcl] {source [info library]:init.tcl}";
-
- /*
- * The following variable is a special hack that allows applications
- * to be linked using the procedure "main" from the Tcl library. The
- * variable generates a reference to "main", which causes main to
- * be brought in from the library (and all of Tcl with it).
- */
-
- extern int main();
- int *tclDummyMainPtr = (int *) main;
-
-
- Tcl_AppInit(interp)
- Tcl_Interp *interp;
- {
- short app_refnum;
- short app_vrefnum;
- Str32 volname;
-
- /* Get application's open resource fork reference number. */
- app_refnum = CurResFile();
-
- /* Get working directory/volume reference number of application. */
- GetVol(volname, &app_vrefnum);
-
- TclMac_CWDInitialize();
- TclMac_InitializeOnce(app_refnum);
-
- Tcl_InitExtended(interp);
-
- Tcl_AddMacintoshCmds(interp);
- Tcl_InitMacintosh(interp);
-
- /*
- ** The following variable is necessary since the damned
- ** ThinkC console behaves so strangely. See help.tcl for
- ** an example of its use.
- */
- Tcl_SetVar(interp, "THINK_CONSOLE", "1", TCL_GLOBAL_ONLY);
-
- if (Tcl_Init(interp) == TCL_ERROR)
- {
- fprintf(stderr, "ERROR in Tcl_Init() --\n");
- fprintf(stderr, " %s\n",
- (interp->result==NULL ? "" : interp->result) );
- }
-
- if (Tcl_ShellEnvInit( interp, TCLSH_INTERACTIVE ) != TCL_OK)
- {
- fprintf(stderr, "ERROR in Tcl_ShellEnvInit() --\n");
- fprintf(stderr, " %s\n",
- (interp->result==NULL ? "" : interp->result) );
- }
-
- tcl_RcFileName = "tclshrc";
-
- return TCL_OK;
- }
-
- void
- Feedback(char *format, ...)
- {
- va_list varg;
-
- va_start(varg, format);
-
- vfprintf(stderr, format, varg);
-
- va_end(varg);
-
- fprintf(stderr, "\n");
- }
-
- int
- mac_printf( char *format_str, ... )
- {
- int result;
- va_list varg;
-
- va_start(varg, format_str);
-
- result = vprintf(format_str, varg);
-
- va_end(varg);
-
- return result;
- }
-
- int
- mac_fprintf( FILE *fp, char *format_str, ... )
- {
- int result;
- va_list varg;
-
- va_start(varg, format_str);
-
- result = vfprintf(fp, format_str, varg);
-
- va_end(varg);
-
- return result;
- }
-
- RotateCursor(phase)
- long phase;
- {
- }
-
- /*
- ** This is called by tcl when an environment variable
- ** is set, giving you the change to keep your code
- ** variables in sync with the $env() tcl variables.
- **
- ** When the tcl code "set env(name) value" is executed
- ** this call is made as:
- ** "check_environment_set_of_globals(name, value)".
- */
- check_environment_set_of_globals(name, value)
- char *name;
- char *value;
- {
- #pragma unused (name, value)
- }
-
- CheckCmdPeriod()
- {
- KeyMap mykeys;
-
- GetKeys(mykeys);
- return (mykeys[1] == 0x00808000);
- }
-
-